<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{Layuimini/lib/layui-v2.6.3/css/layui.css}" href="Layuimini/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" th:href="@{Layuimini/lib/font-awesome-4.7.0/css/font-awesome.min.css}" media="all">
    <link rel="stylesheet" th:href="@{Layuimini/css/public.css}" href="Layuimini/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>

<div class="layui-form layuimini-form">
<!--    <div class="layui-form-item">-->
        <label class="layui-form-label required">网址名称</label>
        <div class="layui-input-block">
            <input type="text" name="superName" id="superName" lay-verify="required"  placeholder="请输入要删除网址的名称" lay-reqtext="网址名称不能为空"  class="layui-input">
        </div>
<!--    </div>-->
<br/>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-danger" lay-submit lay-filter="delBtn">确认删除</button>

            <button class="layui-btn layui-btn-warm" id="resetBtn" type="reset">重置</button>
        </div>

    </div>
</div>
<script th:src="@{LightYear/js/jquery.min.js}" charset="utf-8"></script>
<script th:src="@{Layuimini/lib/layui-v2.6.3/layui.js}" charset="utf-8"></script>
<script th:src="@{Layuimini/js/lay-config.js}" charset="utf-8"></script>
<script>
    layui.use(['iconPickerFa','form','table'], function () {
        var iconPickerFa = layui.iconPickerFa,
            form = layui.form,
            layer = layui.layer,
            table = layui.table,
            $ = layui.$;


        //监听提交
       form.on('submit(delBtn)', function (data) {
           console.log(data.field.superName);
           var superName = data.field.superName;
            this.disabled=true;//防止按钮重复提交
            //删除操作
            $.ajax({
                url:"superUrlFavorite/delSuperUrlFavorite/"+superName,
                type:"DELETE",
                contentType: 'application/json; charset=UTF-8',
                async:false,
                dataType:'json',
                data:JSON.stringify(data.field),
                success:function(result){
                    console.log(result);
                    if(result.code=="20001"){
                       // layer.msg(result.message);
                        layer.msg("网址名称不存在,请核对!");
                    }else{
                         layer.msg('网址删除成功！',{
                      time:2000
                  },function(){
                      window.parent.location.reload();  //刷新父页面
                  })
                    }

                }
            });
            return false;
        });


        $("#resetBtn").click(function () {
            $("input[name='superName']").val("");
           /* layer.msg("重置成功！", {
                    time: 1000, //6s后自动关闭
                    icon:6,
                },function () {
                $("input[name='superName']").val("");
                  //  window.location.reload();
                }
            );*/
        })

    });
</script>
</body>
</html>